﻿// This code is released under the BSD license.
namespace PugLib.Filters
{
    using System.Globalization;
    using Extensions;

    public class SearchFilter
    {
        private string _searchText;

        public SearchFilter()
        {
            SearchText = string.Empty;
        }

        /// <summary>
        /// The field or property to search
        /// </summary>
        public string Field { get; set; }

        /// <summary>
        /// The string or substring of interest
        /// </summary>
        public string SearchText
        {
            get { return _searchText ?? string.Empty; }
            set { _searchText = value; }
        }

        /// <summary>
        /// Abstract search function
        /// </summary>
        public SearchOperator SearchOperator { get; set; }


        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", Field, SearchOperator.GetDescription(), SearchText);
        }
    }
}